import Image from 'next/image'
import { useRouter } from 'next/router'

/**
 * 推荐歌单
 */
function RemdList(props) {
  const { id, imgUrl, play, name } = props

  const route = useRouter()
  return (
    <>
      <span className="remdli" onClick={() => route.push(`/playlist/${id}`)}>
        <div className="listimg">
          <Image src={imgUrl} alt="pic" layout="fill" />
          <span>{play}</span>
        </div>
        <p className="text">{name}</p>
      </span>
      <style jsx>
        {`
          .text {
            overflow: hidden;
            line-height: 1.2;
            font-size: 13px;
            max-height: 30px;
          }
          .remdli {
            display: block;
            float: left;
            width: 33.3%;
            box-sizing: border-box;
            padding: 0 2px;
          }
          .listimg {
            position: relative;
            padding-bottom: 100%;
          }
          .listimg img {
            position: absolute;
            width: 100%;
            top: 0;
            left: 0;
            z-index: 1;
          }
          .listimg span {
            position: absolute;
            right: 5px;
            top: 2px;
            z-index: 3;
            padding-left: 13px;
            color: #fff;
            font-size: 12px;
            background-image: url();
            background-position: 0;
            background-repeat: no-repeat;
            background-size: 11px 10px;
            text-shadow: 1px 0 0 rgba(0, 0, 0, 0.15);
          }
        `}
      </style>
    </>
  )
}

export default RemdList
